home *** CD-ROM | disk | FTP | other *** search
- Form1
- !DataTable Example Program - DEMO1
- wwwwwwwwwwwwwww
- wwwwwwwwwwwwwww
- Form1
- Customer
- DATATABLE
- C:\CUSTOMER
- Label1
- Name:
- CustomerName
- Label2
- Address:
- Address
- Label3
- City:
- Label4
- State:
- State
- Label5
- Label6
- Phone:
- Phone
- TopButton
- NextButton
- InsertButton
- Insert
- DeleteButton
- Delete
- QuitButton
- BottomButton
- Bottom
- PreviousButton
- Previous
- UpdateButton
- Update
- ClearButton
- Clear
- QuitButton_Click
- Form_Click
- Form_Load>
- Customer
- OpenTableg
- Action
- CloseTable%
- FillForm
- GetRecord
- FieldName
- GetField
- CustomerName:
- Text$
- FieldValue
- Address
- StateW
- Phone}
- InsertRecW
- PutField
- InsertRecord
- InsertButton_Click
- ClearButton_Click
- TopButton_Click
- FirstRecord
- BottomButton_Click
- LastRecord
- NextButton_Click
- NextRecord
- PreviousButton_ClickJ
- PreviousRecord
- DeleteButton_Click
- DeleteRecord
- UpdateRec
- UpdateRecord
- UpdateButton_Click
- Reaction
- DisplayError
- TheError
- Form_Unload
- Cancel
- Form_Load
- This code opens the database table (C:\CUSTOMER) and fills in the Visual Basic
- Form with the information present in the first record in the database.
- Open up the database table (Customer.TableName)e
- Fill the form
- QuitButton_Click
- This code closes our database table and terminates the Demo programm
- Close the database table
- Terminate this demoe
- FillForm
- We need to get the current record in the database:
- Ok, now lets get the values in the database fields for the
- record we just read in::
- We need to make a one-to-one relationship between the fields in the database table
- and the fields on our Visual Basic Form. We will read in the field values from the
- database record and place those values into the .TEXT property of our TEXT controlss
- on our Visual Basic form. For each field of interest this is a three-step process:
- 1. Specify the name of the database field of interest ---> DataTable.FieldName = "
- 2. Get the field value ---> DataTable.Action = GetFieldd
- 3. Place the field value in the TEXT control ---> Text1.TEXT = DataTable.FieldValuee
- Thats all there is to it!!
- You should make a FillForm like subroutine position independent. Notice that the first line of
- code in this subroutine reads in the current record. Use other routines to move around
- in the table (like the TOP,BOTTOM, NEXT and PREVIOUS buttons in this demo). Making the
- routine position independent means that it can be used and re-used at any time to fill inn
- your form with information from any record in your database.
- We will fill in the form now:o
- Address"
- State"
- Phone"
- InsertRec
- Here we transfer the information from the Visual Basic Form and insert it
- into the database table.
- To do this requires a three-step process for each field in the database table:
- 1. Specify the name of the field of interest ---> DataTable.FieldNames
- 2. Specify the field value ---> DataTable.FieldValue = A String values
- 3. Put the field into the DataTable record ---> DataTable.Action = PutFieldl
- We do this for each field in the database table.
- When we are finished we INSERT the record into the
- database table ---> DataTable.Action = InsertRecord
- Address"
- State"
- Phone"
- InsertButton_Click
- ClearButton_Click
- This code simply clears the text in all of the Visual Basic form's Text controls..
- TopButton_Click
- The following code moves to the first record in the data basee
- and fills in our form with the information found in that first
- record
- BottomButton_Click
- The following code moves to the last record in the data base
- and fills in our form with the information found in that lastt
- record
- NextButton_Click
- The following code moves to the next record in the database table. If an
- error is encountered during the move to the next record an error message is displayed.
- The DisplayError subroutine is an example of the structure of a generalizedd
- DataTable error handling routine..
- Once the repositioning to the next record is successfull, we fill in our formm
- with information from that record.
- Moving to the next record in the databaseu
- If an error
- Display the DataTable errore
- If no error
- Fill in our form with the information in the record.
- PreviousButton_Click
- The following code moves to the previous record in the database table. If an
- error is encountered during the move to the record an error message is displayed.a
- The DisplayError subroutine is an example of the structure of a generalized
- DataTable error handling routine.
- Once the repositioning to the previous record is successfull, we fill in our formm
- with information from that record.
- Moving to previous recordM
- If an errors
- Display the DataTable Error
- If no error
- Fill in our form with info from the record
- DeleteButton_Click
- This code deletes the current record from the database
- The current record after the delete is performed, is the record immediatelyy
- following the deleted record. We then fill in our form with info from that
- record..
- We will delete the current record.
- Now fill in form with the current record.n
- UpdateRec
- Here we transfer the information from the Visual Basic Form and update the
- current record in the database table.
- To do this requires a three-step process for each field in the database table:
- 1. Specify the name of the field of interest ---> DataTable.FieldNames
- 2. Specify the field value ---> DataTable.FieldValue = A String values
- 3. Put the field into the DataTable record ---> DataTable.Action = PutFieldl
- We do this for each field in the database table.
- When we are finished we UPDATE the record into the
- database table ---> DataTable.Action = UpdateRecordd
- Address"
- State"
- Phone"
- UpdateButton_Click
- DisplayError
- This code is an examle of a DataTable error handling routine..
- It is not a complete error routine but a small example intendedd
- to show how a DataTable error routine can be implemented..
- Drive not ready!
- Directory not found!
- File is busy!"
- File is Locked!"
- File not Found!"
- End of Table!"
- Start of Table!"
- Unknown Error!
-